﻿/*
 * 版 本 v1.0
 * Copyright (c) 2013-2018 广州市同慧信息科技有限公司
 * 创建人：ftquan
 * 日 期：2017.04.18
 * 描 述：查看模型计算结果
 */

var keyValue = request('modelId');
var warnId = request('warnId');
var companyId = request("companyId");
var kjnd = request("kjnd");
var departmentId = request("departmentId");

var userdefault = {};
var selectedRow;

var bootstrap = function ($, learun) {
    "use strict";

    var jfGrid1 = null;

    var page = {
        init: function () {
            page.bind();
            page.initData();
        },
        bind: function () {
            // 优化滚动条
            $('.lr-layout-wrap').lrscroll();
            $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
                // 调用后台查询
                // queryJson 查询条件
                page.search(queryJson);

            }, 200, 888);

            // 报销排名
            jfGrid1 = $('#budgetGrid').jfGrid({
                headData: [
                    {label: '单位', name: 'nameorganization', width: 160, align: 'left'},
                    {label: "年度", name: "yearly", width: 60, align: "center"},
                    {label: '部门', name: 'namedepartment', width: 160, align: 'left'},
                    {
                        label: '报销额', name: 'amount', width: 110, align: 'right', statistics: true,
                        formatter: function (cellvalue) {
                            return $.formatMoney(cellvalue, 2)
                        }
                    },
                    {label: '电话', name: 'telphonenumber', width: 110, align: 'center'},
                    {label: '报销人', name: 'paymentperson', width: 110, align: 'center'},
                    {label: '日期', name: 'createdate', width: 140, align: 'center'},
                    {label: '报销内容', name: 'content', width: 1, align: 'left'}
                ],
                isPage: true
            });

        },
        initData: function () {
            if (!!keyValue) {
              page.search();
            }
        },
        search: function (param) {
            param = param || {};
            param.companyId = companyId;
            param.kjnd = kjnd;
            param.departmentId = departmentId;
            var content = $("#content").val();
            param.content = content;
            page.refreshData(param);
        },
        refreshData: function (param) {
            learun.httpAsync('GET', config.base_server() + 'reimburseReceipts/pageAll?modelId=' + keyValue + '&access_token=' + config.getToken().access_token, param, function (data) {
                $('.lr-layout-wrap').lrSetFormData(data);
                $("#modelName").html(data.modelName);
                $('#budgetGrid').jfGridSet('refreshdata', data);
            });
        }
    };

    page.init();
}
